// import Server from '@/config/server';
import request from '@/utils/request';
import { showErrors, showError, showSuccess } from '@/utils/showMsg';

const state = {
  List: [],
  fields: [], // fields
  Listfields: [],
};


const actions = {
  GetFields({ commit }, data) {
    let fields = [
      {
        title: '序号',
        dataIndex: 'cate_id',
        align: 'center',
      },
      {
        title: '分类名称',
        dataIndex: 'cate_name',
        align: 'center',
      },
      {
        title: '分类状态',
        dataIndex: 'status',
        align: 'center',
        scopedSlots: { customRender: 'status' },
      },
      {
        title: '排序',
        dataIndex: 'order',
        align: 'center',
        defaultSortOrder: 'descend',
        sorter: (a, b) => b.order - a.order,
        // scopedSlots: { customRender: 'tag' },
      },
      {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' },
        align: 'center',
        width: 160,
      }
    ];
    commit('setfields', fields);
  },
  GetListFields({ commit }, data) {
    let fields = [
      {
        title: '序号',
        dataIndex: 'id',
        align: 'center',
        width: 100
      },
      {
        title: '标题',
        dataIndex: 'theme',
        align: 'center',
      },
      {
        title: '封面图',
        dataIndex: 'image',
        align: 'center',
        width: 100,
        scopedSlots: { customRender: 'image' },
      },
      {
        title: '直播状态',
        dataIndex: 'status_id',
        align: 'center',
        scopedSlots: { customRender: 'status' },
      },
      {
        title: '所属分类',
        dataIndex: 'cate_list',
        align: 'center',
        scopedSlots: { customRender: 'cate' },
      },
      {
        title: '是否发布',
        dataIndex: 'is_open',
        scopedSlots: { customRender: 'is_open' },
        align: 'center',
      },
      {
        title: '直播时长',
        dataIndex: 'living_duration',
        align: 'center',
      },
      {
        title: '直播开始时间',
        dataIndex: 'reserve_start',
        align: 'center',
      },
      {
        title: '创建时间',
        dataIndex: 'create_time',
        align: 'center',
      },
      {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' },
        align: 'center',
        width: 180,
      }
    ];
    commit('setListfields', fields);
  },
};

const mutations = {
  setfields(state, lists) {
    // console.log(state)
    state.fields = lists;
  },
  setListfields(state, lists) {
    // console.log(state)
    state.Listfields = lists;
  },
};

export default {
  namespaced: true,
  state,
  actions,
  mutations
};
